/*
* Copyright (C) 2020 ~ 2024 chaigec All Rights Reserved.
*
* Author:     chaigec <chaigec@163.com>
* Maintainer: chaigec <chaigec@163.com>

 * Use of this source code is governed by MIT license that can be found in the
 * LICENSE file in the root of the source tree. All contributing project authors
 * may be found in the AUTHORS file in the root of the source tree.
*/

#include "MkSipTransaction.h"
#include "MkSipHeader.h"
#include "MkSipTcpSession.h"
#include "MkSipListener.h"
#include "MkUtil/MkLog.h"                                                       

CMkSipTransaction::CMkSipTransaction()
    : m_CreateTime(NowMkTime)
{

}

void CMkSipTransaction::SetRequest(const CMkSipMessage& SipRequest)
{
    m_Request = SipRequest;
}

void CMkSipTransaction::SetLastResponse(const CMkSipMessage& SipResponse)
{
    m_LastResponse = SipResponse;
    //if callee and invite,  ack message set complete time
    if (InviteCallee == m_Type
        && MkSipMethodInvite == m_Request.GetMethod()
        && MkSipStatusOK == SipResponse.GetStatusCode()) {
        return;
    }
    if (MkSipStatusOK <= SipResponse.GetStatusCode()) {
        m_CompleteTime = NowMkTime;
    }
}

CMkSipTransaction::~CMkSipTransaction()
{

}

